package com.example.allinone.homework08.fragment2;

import android.content.Context;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import com.example.allinone.homework08.User;

@Database(entities = {User.class},version = 1,exportSchema = false)
public abstract class MyRoom extends RoomDatabase {
    private  static MyRoom instance ;
    public abstract  UserDao userDao() ;
    static MyRoom getInstance(Context context){
        if(instance==null){
            instance = Room.databaseBuilder(context.getApplicationContext(),
                    MyRoom.class,"room")
                    .allowMainThreadQueries().build();
        }
        return instance ;
    }
}
